<?php
/**
 * JoiGallery - image gallery component for Joostina
 *
 * Backend toolbar handler
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	Admin
 * @filename toolbar.joigallery.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/

defined('_VALID_MOS') or die();

$act = mosGetParam($_REQUEST, 'act');
$cid = intval(mosGetParam($_GET,'cid','0'));

if (empty($act)) return;

if ($act == 'configuration') {
	switch ($task) {	
		case 'new':
		case 'config':
			            mosMenuBar::startTable();
						if (mosGetParam($_REQUEST, 'group')) {
							mosMenuBar::ext(_APPLY,'#','-apply','id="tb-apply" onclick="return ch_apply();"');
						}	
                        mosMenuBar::spacer();
			            mosMenuBar::save();
			            mosMenuBar::spacer();
			            mosMenuBar::cancel();
			            mosMenuBar::endTable();		
			            break;
			
		case 'config_list':
		default:
			            mosMenuBar::startTable();
			            mosMenuBar::addNew();
			            mosMenuBar::spacer();
			            mosMenuBar::deleteList();
                        mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
			            mosMenuBar::endTable();	
			            break;			
	}
    return;
}
if ($act == 'extrafields') {
	switch ($task) {		
		case 'new':
		case 'extrafield':
			            mosMenuBar::startTable();            
			            mosMenuBar::apply();
                        mosMenuBar::spacer();
			            mosMenuBar::save();
			            mosMenuBar::spacer();
			            mosMenuBar::cancel();
			            mosMenuBar::endTable();		
			            break;
			
		case 'extrafield_list':
		default:
			            mosMenuBar::startTable();
			            mosMenuBar::addNew();
			            mosMenuBar::spacer();
			            mosMenuBar::deleteList();
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_TOOLS,'index2.php?option=com_joigallery&amp;act=tools','-tools','');
			            mosMenuBar::endTable();	
			            break;			
	}
    return;
}
if ($act == 'plugins') {
	switch ($task) {
		case 'plugin':
			            mosMenuBar::startTable();
                        mosMenuBar::apply();
                        mosMenuBar::spacer();
			            mosMenuBar::save();
			            mosMenuBar::spacer();
			            mosMenuBar::cancel('cancel',_CLOSE);
			            mosMenuBar::endTable();		
			            break;
			
		case 'plugins_list':
		default:
			            mosMenuBar::startTable();
			            mosMenuBar::deleteList();
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_TOOLS,'index2.php?option=com_joigallery&amp;act=tools','-tools','');
			            mosMenuBar::endTable();	
			            break;			
	}
    return;
}
if ($act == 'photos') {
    switch ($task) {
        case 'new':
	  		            mosMenuBar::startTable();        
                        mosMenuBar::addNew('upload',_C_JOIGALLERY_UP);                       
			            //mosMenuBar::back();
                        //mosMenuBar::cancel();
						mosMenuBar::cancel('cancel',_CLOSE);
                        //mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
			            mosMenuBar::endTable();
            break;
        case 'edit':
                        mosMenuBar::startTable();
                        mosMenuBar::spacer();
                        //mosMenuBar::apply();
                        mosMenuBar::ext(_APPLY,'#','-apply','id="tb-apply" onclick="return ch_apply();"');
                        mosMenuBar::spacer();
                        mosMenuBar::save();
                        mosMenuBar::spacer();
                        mosMenuBar::cancel('cancel',_CLOSE);
                        mosMenuBar::endTable();
            break;

        case 'move':
                        mosMenuBar::startTable();
                        mosMenuBar::spacer();                        
                        mosMenuBar::customX('savemove','-move',null,_MOVE);
                        mosMenuBar::spacer();
                        mosMenuBar::cancel();
                        mosMenuBar::endTable();
            break;

        default:
                        mosMenuBar::startTable();
                        mosMenuBar::ext(_C_JOIGALLERY_UP,'index2.php?option=com_joigallery&amp;act=photos&amp;task=new','-new','');
                        mosMenuBar::spacer();
                        mosMenuBar::editListX();
                        mosMenuBar::spacer();
                        mosMenuBar::customX('move','-move',null,_MOVE);
                        mosMenuBar::spacer();
                        mosMenuBar::publishList();
                        mosMenuBar::spacer();
                        mosMenuBar::unpublishList();
                        mosMenuBar::spacer();
                        mosMenuBar::deleteListX();                        
                        mosMenuBar::spacer();                        
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
                        mosMenuBar::endTable();
            break;
    }
    return;
}
if ($act == 'tools') {

			            mosMenuBar::startTable();
                        mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_CONFIGURATION,'index2.php?option=com_joigallery&amp;act=configuration','-configuration','');
			            mosMenuBar::endTable();

    return;
}
if ($act == 'thumbs') {

			            mosMenuBar::startTable();
						//mosMenuBar::save();
                        //mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::customX('thumbuild','-thumb',null,_C_JOIGALLERY_EXEC);
                        //mosMenuBar::customX('savemove','-move',null,_MOVE);
						mosMenuBar::spacer();
                        //mosMenuBar::cancel('cancel',_CLOSE);                        
                        mosMenuBar::ext(_BACK,'index2.php?option=com_joigallery&amp;act=tools','-tools','');
			            mosMenuBar::endTable();

    return;
}
if ($act == 'about') {

			            mosMenuBar::startTable();
                        mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_CATEGORIES,'index2.php?option=com_joigallery&amp;act=categories','-categories','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_TOOLS,'index2.php?option=com_joigallery&amp;act=tools','-tools','');
                        mosMenuBar::spacer();
                        mosMenuBar::ext(_C_JOIGALLERY_CONFIGURATION,'index2.php?option=com_joigallery&amp;act=configuration','-configuration','');                                               
			            mosMenuBar::endTable();

    return;
}
switch ($task) {
    case 'new':
    case 'edit':
			            mosMenuBar::startTable();
			            mosMenuBar::spacer(); 
			            if($cid) // используем Ajax кнопку "Применить" только для уже существующей категории
			            // кнопка "Применить" с Ajax
			            mosMenuBar::ext(_APPLY,'#','-apply','id="tb-apply" onclick="return ch_apply();"');
			            else 
						mosMenuBar::apply();
			            mosMenuBar::spacer();
			            mosMenuBar::save();
			            mosMenuBar::spacer();		
			            if($cid) mosMenuBar::cancel('cancel',_CLOSE);
			            else     mosMenuBar::cancel();
			            mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
			            mosMenuBar::endTable();
			            break;
						
    case 'move':
                        mosMenuBar::startTable();
                        mosMenuBar::spacer();                        
                        mosMenuBar::customX('savemove','-move',null,_MOVE);
                        mosMenuBar::spacer();
                        mosMenuBar::cancel();
                        mosMenuBar::endTable();
        			    break;

    default:
			            mosMenuBar::startTable();
			            mosMenuBar::addNewX();
			            mosMenuBar::spacer();
			            mosMenuBar::editListX();
			            mosMenuBar::spacer();
						mosMenuBar::customX('move','-move',null,_MOVE);
                        mosMenuBar::spacer();
			            mosMenuBar::publishList();
			            mosMenuBar::spacer();
			            mosMenuBar::unpublishList();
			            mosMenuBar::spacer();
			            mosMenuBar::deleteListX();
			            mosMenuBar::ext(_C_JOIGALLERY_PHOTOS,'index2.php?option=com_joigallery&amp;act=photos','-photos','');
			            mosMenuBar::endTable();
			            break;
}
?>